import { Injectable } from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {MsgResult} from '../../../models/msg-result';
import {DataAuditAPI} from '../data-audit-constants';
import {RequestUtil} from '../../../util/request-util';
import {FormUtil} from '../../../util/form-util';

@Injectable()
export class DataAuditAdjustService {

  constructor(
    private requestUtil: RequestUtil,
    private formUtil: FormUtil
  ) { }

  /**
   * 获取表格数据
   * data
   * @returns {Observable<MsgResult>}
   */
  getTableHeadData(data): Observable<MsgResult> {
    const params = this.formUtil.serialize(data);
    return this.requestUtil.get(DataAuditAPI.getAuditData, params);
  }

  /**
   * 获取表格数据
   * @returns {Observable<MsgResult>}
   */
  getDataSource(): Observable<MsgResult> {
    return this.requestUtil.get(DataAuditAPI.getDsConfInfos);
  }

  /**
   * 获取表格数据
   * data
   * @returns {Observable<MsgResult>}
   */
  postAuditData(data): Observable<MsgResult> {
    const params = this.formUtil.serialize(data);
    return this.requestUtil.post(DataAuditAPI.postAuditData, params);
  }
}
